Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline function defintion error #799

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from

Conversation

Mq-b
Copy link

@Mq-b Mq-b commented Jan 27, 2024

The original description is unclear:

You can declare functions in a way that allows the compiler to expand them inline rather than calling them through the usual function call mechanism.

I think it should be emphasized that defining inline functions, whether with the standard C++ keyword 'inline' or some other compiler extension, is just a 'suggestion'. The original text seems unclear.

The compiler can inline a function whether or not it is defined inline.

cppreference:

Since this meaning of the keyword inline is non-binding, compilers are free to use inline substitution for any function that's not marked inline, and are free to generate function calls to any function marked inline. Those optimization choices do not change the rules regarding multiple definitions and shared statics listed above.

Inline variables eliminate the main obstacle to packaging C++ code as header-only libraries.
(since C++17)


In the previous Microsoft documentation, there was also some discussion of inline functions:

MicrosoftDocs/cpp-docs#4823

Copy link

google-cla bot commented Jan 27, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@vapier vapier added the lang:cpp The C++ language label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:cpp The C++ language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants